package com.njiandan.johnson.vr360library.programs;

import android.content.Context;
import android.opengl.GLES20;

import com.njiandan.johnson.vr360library.utils.ShaderUtils;

/**
 * author：johnsonZhang on 2017/3/21 16:28
 * email：15915356@qq.com
 */
public class GLOESProgram extends GLAbsProgram {
    private int muSTMatrixHandle;
    private int uTextureSamplerHandle;

    public GLOESProgram(Context context) {
        super(context, "filter/vsh/oes.glsl", "filter/fsh/oes.glsl");
    }

    @Override
    public void create() {
        super.create();
        muSTMatrixHandle = GLES20.glGetUniformLocation(getProgramId(), "uSTMatrix");
        ShaderUtils.checkGlError("glGetUniformLocation uSTMatrix");
        if (muSTMatrixHandle == -1) {
            throw new RuntimeException("Could not get attrib location for uSTMatrix");
        }

        uTextureSamplerHandle = GLES20.glGetUniformLocation(getProgramId(), "sTexture");
        ShaderUtils.checkGlError("glGetUniformLocation uniform samplerExternalOES sTexture");
    }

    public int getMuSTMatrixHandle() {
        return muSTMatrixHandle;
    }

    public int getUTextureSamplerHandle() {
        return uTextureSamplerHandle;
    }
}
